home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / packagetool / utilities.h < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  6.4 KB  |  143 lines

  1. /*
  2.     File: Utilities.h
  3.     
  4.     Description:
  5.         This file contains a number of utility routines used in the
  6.     PackageTool application.  these routines have been moved here
  7.     to simplify the example.
  8.     
  9.     PackageTool is an application illustrating how to create application
  10.     packages in Mac OS 9.  It provides a simple interface for converting
  11.     correctly formatted folders into packages and vice versa.
  12.  
  13.     Copyright:
  14.         © Copyright 1999 Apple Computer, Inc. All rights reserved.
  15.     
  16.     Disclaimer:
  17.         IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  18.         ("Apple") in consideration of your agreement to the following terms, and your
  19.         use, installation, modification or redistribution of this Apple software
  20.         constitutes acceptance of these terms.  If you do not agree with these terms,
  21.         please do not use, install, modify or redistribute this Apple software.
  22.  
  23.         In consideration of your agreement to abide by the following terms, and subject
  24.         to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  25.         copyrights in this original Apple software (the "Apple Software"), to use,
  26.         reproduce, modify and redistribute the Apple Software, with or without
  27.         modifications, in source and/or binary forms; provided that if you redistribute
  28.         the Apple Software in its entirety and without modifications, you must retain
  29.         this notice and the following text and disclaimers in all such redistributions of
  30.         the Apple Software.  Neither the name, trademarks, service marks or logos of
  31.         Apple Computer, Inc. may be used to endorse or promote products derived from the
  32.         Apple Software without specific prior written permission from Apple.  Except as
  33.         expressly stated in this notice, no other rights or licenses, express or implied,
  34.         are granted by Apple herein, including but not limited to any patent rights that
  35.         may be infringed by your derivative works or by other works in which the Apple
  36.         Software may be incorporated.
  37.  
  38.         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  39.         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  40.         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  41.         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  42.         COMBINATION WITH YOUR PRODUCTS.
  43.  
  44.         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  45.         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  46.         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47.         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  48.         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  49.         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  50.         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  51.  
  52.     Change History (most recent first):
  53.         Fri, Dec 17, 1999 -- created
  54. */
  55.  
  56.  
  57. #ifndef __UTILITIES__
  58. #define __UTILITIES__
  59.  
  60. #define TARGET_API_MAC_CARBON 1
  61.  
  62. #include <MacTypes.h>
  63. #include <Files.h>
  64. #include <Aliases.h>
  65. #include <Drag.h>
  66. #include <Icons.h>
  67. #include <QDOffscreen.h>
  68. #include <Script.h>
  69.  
  70.  
  71. /* ValidFSSpec verifies that *spec refers is formatted correctly, and it
  72.     verifies that it refers to an existing file in an existing directory on
  73.     and existing volume. If *spec is valid, the function returns noErr,
  74.     otherwise an error is returned. */
  75. OSErr ValidFSSpec(FSSpec *spec);
  76.  
  77.  
  78. /* ResolveAliasQuietly resolves an alias using a fast search with no user interaction.  Our main loop
  79.     periodically resolves gFileAlias comparing the result to gTargetFile to keep the display up to date.
  80.     As a result, we would like the resolve alias call to be as quick as possible AND since the application
  81.     may be in the background when  it is called, we don't want any user interaction. */
  82. OSErr ResolveAliasQuietly(ConstFSSpecPtr fromFile, AliasHandle alias, FSSpec *target, Boolean *wasChanged);
  83.  
  84.  
  85. /* GrayOutBox grays out an area of the screen in the current grafport.  
  86.     *theBox is in local coordinates in the current grafport. This routine
  87.     is for direct screen drawing only.  */
  88. void GrayOutBox(Rect *theBox);
  89.  
  90.  
  91. /* ShowDragHiliteBox is called to hilite the drop box area in the
  92.     main window.  Here, we draw a 3 pixel wide border around *boxBounds.  */
  93. OSErr ShowDragHiliteBox(DragReference theDragRef, Rect *boxBounds);
  94.  
  95.  
  96. /* FSpGetDirID returns the directory ID number for the directory
  97.     pointed to by the file specification record *spec.  */
  98. OSErr FSpGetDirID(FSSpec *spec, long *theDirID);
  99.  
  100.  
  101. /* UpdateRelativeAliasFile updates the alias file located at
  102.      aliasDest referring to the targetFile.  relative path
  103.      information is stored in the new file. */
  104. OSErr UpdateRelativeAliasFile(FSSpec *theAliasFile, FSSpec *targetFile, Boolean createIfNecessary);
  105.  
  106.  
  107. /* FileSharingAppIsRunning returns true if the file sharing
  108.     extension is running. */
  109. Boolean FileSharingAppIsRunning(void);
  110.  
  111.  
  112. /* FSSpecIsInDirectory returns true if the file system object
  113.     referred to by theSpec is somewhere in the directory referred
  114.     to by (vRefNum, dirID) */
  115. Boolean FSSpecIsInDirectory(FSSpec *theSpec, short vRefNum, long dirID);
  116.  
  117.  
  118. /* FSSpecIsAFolder returns true if the FSSpec pointed
  119.     to by target refers to a folder. */
  120. Boolean FSSpecIsAFolder(FSSpec *target);
  121.  
  122.  
  123. /* ShowChangesInFinderWindow asks the finder redraw a directory
  124.     window by either sending a update container event to the
  125.     finder if this facility exists, or by bumping the parent directorie's
  126.     modification date */
  127. OSErr ShowChangesInFinderWindow(short vRefNum, long dirID);
  128.  
  129.  
  130. /* NavReplyToODOCList converts a document list returned by a Navigation Services
  131.     dialog into a document list structure that is the same format as the one
  132.     the system sends to your application's open document Apple event handler
  133.     routine.  Replies returned by Navigation Services may contain special
  134.     references to folders that may be incompatible with some document opening
  135.     strategies or routines.  By converting navigation replies into 'odoc' list
  136.     format, your application only needs to implement one document opening
  137.     routine that receives dcoument lists from both Apple events and navigation
  138.     services.  NOTE:  this is really only an issue if your application is set
  139.     up to open packages or folders. */
  140. OSStatus NavReplyToODOCList(AEDescList *navReply, AEDescList *odocList);
  141.  
  142. #endif
  143.